using System;
using System.Collections.Generic;
using UnityEngine;

public class AnimatorOverrideСhoice : MonoBehaviour
{
	[Serializable]
	public struct AnimationOverrideProbality
	{
		public AnimatorOverrideController controller;

		public float probality;
	}

	private Animator _animator;

	public List<AnimationOverrideProbality> AOPlist;

	private void Awake()
	{
		_animator = GetComponent<Animator>();
		if (AOPlist.Count != 0)
		{
			float num = 0f;
			int i;
			for (i = 0; i < AOPlist.Count; i++)
			{
				num += AOPlist[i].probality;
			}
			float num2 = UnityEngine.Random.Range(0f, 1f) * num;
			float num3 = 0f;
			for (i = 0; i < AOPlist.Count && !(num3 + AOPlist[i].probality >= num2); i++)
			{
				num3 += AOPlist[i].probality;
			}
			Animator component = GetComponent<Animator>();
			component.runtimeAnimatorController = AOPlist[i].controller;
			component.SetLayerWeight(1, 0f);
		}
	}
}
